﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mathematics.Parser
{
    public class ExpressionContainer:IEnumerable<ExpressionRelationship>
    {
        private LinkedList<ExpressionRelationship> _innerList = new LinkedList<ExpressionRelationship>();

        public ExpressionContainer(TokenString expression,Domain domain)
        {
            Domain = domain;

            var item = expression.First;
            do
            {
                Add(item);
                item = item.Next;
            } while (item != null);
        }

        public Domain Domain { get; private set; }

        private void Add(LinkedListNode<Token> item)
        {
            _innerList.Add(new ExpressionRelationship(item, this));
        }

        #region IEnumerable<ExpressionRelationship> Members

        public IEnumerator<ExpressionRelationship> GetEnumerator()
        {
            return _innerList.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return _innerList.GetEnumerator();
        }

        #endregion
    }
}
